<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>正则表达式</title>
    <script>
        var regExp = new RegExp("^\\w{6,12}$");

        var reg = /^\w{6,12}$/;

        var username = "123456789abc";
        var flag = regExp.test(username)
        document.write(flag+"<br/>");
        document.write(reg.test(username));
    </script>
</head>
<body>

</body>
</html>